<template>
	<view class="container">
		<view class="header">
			<view class="u-f-jsb">
				<view>商户名称</view>
				<view>{{userinfo.sharerName}}</view>
			</view>
			<view class="u-f-jsb">
				<view>登录账号</view>
				<view>{{userinfo.userCode}}</view>
			</view>
		</view>
		<!-- <view class="card1 u-f-jsb" hover-class="tap-active" data-url="./searchUser/searchUser" @tap="$jumpPage"> 
			<view class="u-f-jsb" >
				<image class="icon-qianbao" src="/static/images/icon-qianbao.png" mode="aspectFill"></image>
				<view>充值/加注卡</view>
			</view>
			<image class="icon-arrow-r" src="/static/images/icon-arrow-r.png" mode="aspectFill"></image>
		</view> -->
		<view class="card1 u-f-jsb" hover-class="tap-active" data-url="bindWxAccount/bindWxAccount" @tap="$jumpPage">
			<view class="u-f-jsb" >
				<image class="icon-qianbao" src="/static/images/icon-qianbao.png" mode="aspectFill"></image>
				<view>收款微信号</view>
			</view>
			<view class="u-f-ajc">
				<view>
					<text style="margin-right: 20rpx;color: #FF9239;" v-if="bindedWxInfo.payeeOpenId">已绑定</text>
					<text style="margin-right: 20rpx;color: #808080;" v-else >未绑定</text>
				</view>
				<image class="icon-arrow-r" src="/static/images/icon-arrow-r.png" mode="aspectFill"></image>
			</view>
		</view>
		<view class="card2" v-if="userinfo.isMain==1">
			<view class="add u-f-jsb" data-url="addAccount/addAccount" @tap="$jumpPage">
				<view class=" u-f-ac"  >
					<image src="/static/images/icon-add.png" mode="aspectFill"></image>
					<view>添加子账号</view>
				</view>
				<image class="icon-arrow-r" src="/static/images/icon-arrow-r.png" mode="aspectFill"></image>
			</view>
			<view class="list">  
				
				<block v-for="(item,index) in list" :key="index">
					<view class="item" 
						hover-class="tap-active" 
						:data-url="`/pages/accountManage/accountDetail/accountDetail?item=`+encodeURIComponent(JSON.stringify(item))"
						@tap="$jumpPage"
					>
						<view class=" u-f-jsb">
							<view class="item-l">
								<view class="u-f-ac">
									<view>{{item.userName}}</view>
									<view class="label" v-if="item.userMain==2">推广员</view>
								</view>
								<view class="phone">{{item.userCode}}</view>
							</view>
							<image class="item-r" src="/static/images/icon-arrow-r.png" mode="aspectFill"></image>
						</view>
					</view>
				</block>
			</view>
		</view>
		 
		<view class="btn u-f-ajc" hover-class="tap-active" @tap="loginOut">退出登录</view>
	</view>
</template>

<script> 
	export default {
		data() {
			return {
				list:[]
			};
		},
		computed: {
			userinfo() {
				return this.$store.state.userinfo;
			},
			bindedWxInfo() {
				return this.$store.state.bindedWxInfo;
			}
		},
		onLoad() {
			this.getAccountList();
			uni.$on('editAccount',this.getAccountList);
		},
		onUnload() {
			uni.$off('editAccount');
		},
		methods:{
			// 获取子账号列表
			getAccountList() {
				this.$u.api._subaccountList().then(res => {
					this.list = res;
				})
			},
			loginOut() {
				uni.showModal({
					title:'提示',
					content:'您确定要退出登录吗',
					success: (res) => {
						if(res.confirm) {
							uni.clearStorage();
							uni.reLaunch({
								url:'/pages/login/login'
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
 page{
	 background-color: RGBA(245, 245, 245, 1);
 }
 
 .container {
	 // padding: 20rpx;
 }
 .header {
	 background-color: #FFFFFF;
	 padding: 30rpx 60rpx;
	 >view {
		font-size: 30rpx;
		line-height: 80rpx;
		>view:nth-child(1) {
			color: rgba(154, 154, 154, 1);
		}
	 }
 }
 
 .card1 {
	 margin: 20rpx;
	 border-radius: 16rpx;
	 background-color: #FFFFFF;
	 height: 140rpx;
	 padding: 0 40rpx;
	 font-size: 32rpx;
	 
	 .icon-qianbao {
		 width: 48rpx;
		 height: 52rpx;
		 margin-right: 30rpx;
	 }
	 .icon-arrow-r {
		 width: 16rpx;
		 height: 30rpx;
	 }
 }
 
 .card2 {
	margin: 20rpx;
	background-color: #FFFFFF;
	border-radius: 16rpx;
	font-size: 32rpx;
	font-weight: 600;
	overflow: hidden;
	.add {
		padding: 40rpx;
		image {
			 width: 48rpx;
			 height: 48rpx;
			 flex-shrink: 0;
			 margin-right: 30rpx;
			 font-size: 32rpx;
		}
		
		&:last-child {
			padding-bottom: 60rpx;
		}
		.icon-arrow-r {
			 width: 16rpx;
			 height: 30rpx;
			 margin: 0;
		}
	}
	
 }
 
 .list {
	 border-radius: 16rpx;
	 background-color: #FFFFFF;
	 margin-bottom: 20rpx;
	
	.item {
		padding:0 30rpx;
		background-color: rgba(246, 246, 246, 1);
		margin: 0 25rpx 20rpx 60rpx;
		border-radius: 8rpx;
		overflow: hidden;
		&>view {
			padding: 20rpx 0;
		}
		.item-l {
			overflow: hidden;
			flex: 1;
			font-size: 36rpx;
			font-weight: 600;
			.phone {
				color: #999999;
				font-size: 32rpx;
				margin-top: 10rpx;
				font-weight: 400;
			}
			.label {
				width: 110rpx;
				height: 44rpx;
				line-height: 44rpx;
				text-align: center;
				background-color: #FF9239;
				color: #FFFFFF;
				font-size: 26rpx;
				border-radius: 8rpx;
				margin-left: 60rpx;
			}
		}
		.item-r{
			width: 16rpx;
			height: 30rpx;
			flex-shrink: 0;
			padding: 20rpx 10rpx;
		}
	}
 }
 .btn {
 	width: 710rpx;
 	background-color: rgba(50, 62, 86, 1);
 	height: 90rpx;	
 	font-size: 28rpx;
 	border-radius: 20rpx; 
	margin: 20rpx;
	color: #FFFFFF;
 }

</style>
